import Vue from 'vue'
import Vuex from 'vuex'

Vue.use(Vuex)

export default new Vuex.Store({
  state: {
    title: [
      "产品名称",
      "产品编号",
      "修改时间",
      "成本价",
      "库存数",
      "总价",
      "登记人",
      "操作",
    ],
    arr: [
      {
        pname: "联想笔记本电脑",
        id: 1,
        uptDate: new Date(),
        price: 6000,
        count: 50,
        user: "张三",
        isShow: true,
        isCheck: false
      },
      {
        pname: "宏基笔记本电脑",
        id: 2,
        uptDate: new Date(),
        price: 8000,
        count: 30,
        user: "里斯",
        isShow: true,
        isCheck: false
      },
    ]
  },
  getters: {
    timer() {
      let now = new Date();
      let year = now.getFullYear();
      let mout = now.getMonth() + 1;
      let day = now.getDate();
      let hours = now.getHours();
      let minutes = now.getMinutes();
      return year + "-" + mout + "-" + day + "  " + hours + ":" + minutes
    }
  },
  mutations: {
    addarr(state, payload) {
      state.arr.push(payload)
    },
    del(state, payload) {
      state.arr.splice(payload, 1);
    }
  },
  actions: {
  },
  modules: {
  }
})
